package cn.onein.edu.web.controller;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import cn.onein.edu.web.common.base.BaseController;
import cn.onein.edu.web.jms.producer.SendMailProducer;

/**
 * 一些静态内容的展示
 * @author Upton
 *
 */
@Controller
public class StaticPageController extends BaseController {
	
	Logger logger = Logger.getLogger(StaticPageController.class);
	
	@Autowired
	private SendMailProducer sendMailProducer;
	
	/**
	 * 服务条款
	 * @return
	 */
	@RequestMapping(value = "/terms", method = { RequestMethod.GET,	RequestMethod.POST })
	public ModelAndView terms(){
		ModelAndView mv = new ModelAndView("static/terms");
		
		setMenu(mv, MENU_VALUE_TERMS);
		
		return mv;
	}
	
	/**
	 * 会员服务条款
	 * @return
	 */
	@RequestMapping(value = "/member-terms", method = { RequestMethod.GET,	RequestMethod.POST })
	public ModelAndView memberTerms(){
		ModelAndView mv = new ModelAndView("static/member-terms");
		
		setMenu(mv, MENU_VALUE_MEMBER_TERMS);
		
		return mv;
	}
	
	/**
	 * 帮助中心
	 * @return
	 */
	@RequestMapping(value = "/help", method = { RequestMethod.GET,	RequestMethod.POST })
	public ModelAndView help(){
		ModelAndView mv = new ModelAndView("static/help");
		
		setMenu(mv, MENU_VALUE_HELP);
		
		return mv;
	}
	
	/**
	 * 关于我们
	 * @return
	 */
	@RequestMapping(value = "/about", method = { RequestMethod.GET,	RequestMethod.POST })
	public ModelAndView about(){
		ModelAndView mv = new ModelAndView("static/about");
		
		setMenu(mv, MENU_VALUE_ABOUT);
		
		return mv;
	}
	
	/**
	 * 意见反馈
	 * @return
	 */
	@RequestMapping(value = "/feedback", method = { RequestMethod.GET,	RequestMethod.POST })
	public ModelAndView feedback(){
		ModelAndView mv = new ModelAndView("static/feedback");
		
		setMenu(mv, MENU_VALUE_FEEDBACK);
		
		return mv;
	}
	
	/**
	 * 提交意见反馈
	 * @return
	 */
	@RequestMapping(value = "/feedback/doFeedBack", method = { RequestMethod.GET,	RequestMethod.POST })
	public ModelAndView doFeedBack(String title,String mobile,String email,String content){
		ModelAndView mv = new ModelAndView("static/feedback");
		
		try{
			sendMailProducer.sendFeedBackMessage(title, mobile, email, content);
		}catch(Exception e){
			logger.error("Send feedback email error.", e);
		}
		
		setMenu(mv, MENU_VALUE_FEEDBACK);
		
		return mv;
	}
	
	/**
	 * 联系我们
	 * @return
	 */
	@RequestMapping(value = "/contacts", method = { RequestMethod.GET,	RequestMethod.POST })
	public ModelAndView contacts(){
		ModelAndView mv = new ModelAndView("static/contacts");
		
		setMenu(mv, MENU_VALUE_CONTACT);
		
		return mv;
	}
	
	/**
	 * 专家团队
	 * @return
	 */
	@RequestMapping(value = "/team", method = { RequestMethod.GET,	RequestMethod.POST })
	public ModelAndView team(){
		ModelAndView mv = new ModelAndView("static/team");
		
		setMenu(mv, MENU_VALUE_EDU_TEAM);
		
		return mv;
	}
}
